package com.xczz.common;

import lombok.Data;

@Data
public class Result<T> {
    private int code;   // 业务状态码
    private String msg; // 提示信息
    private T data;     // 数据

    // 成功静态方法
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMsg("成功");
        result.setData(data);
        return result;
    }

    // 错误静态方法
    public static <T> Result<T> error(int code, String msg) {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}